<html>
<script src="../timer/timer.js"></script>
<script>
JerryTimer.start();
var p = new Promise(function(resolveJerry, reject){
    console.log("inside Promise constructor: " + JerryTimer.end());
    JerryTimer.start();
    setTimeout(function(){
        console.log('执行完成: ' + JerryTimer.end());
        JerryTimer.start();
        resolveJerry('随便什么数据');
    }, 4000);
    console.log("do a heavy task begin!!");
    JerryTimer.block(2);
    console.log("do a heavy task end!!: " + JerryTimer.end());
    JerryTimer.start();

}); // this p will immediately be executed

console.log("outside p");

var thenCallback = function(result){
	setTimeout( (function(result){
		 return function(){
		 	console.log("in then function: " + result + " consumed time: " + 	JerryTimer.end());
		 }	
	})(result), 5000);
}
/*
p.then(
	setTimeout(
		function(result){
			console.log("in then function: " + result + " consumed time: " + 	JerryTimer.end());	
	}, 1000));
*/
JerryTimer.start();
p.then(thenCallback);
console.log("after p.then");
</script>
</html>